home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-SPAR.{_A / SBUS.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  4KB  |  109 lines

  1. /* $Id: sbus.h,v 1.10 1998/12/16 04:33:58 davem Exp $
  2.  * sbus.h:  Defines for the Sun SBus.
  3.  *
  4.  * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
  5.  */
  6.  
  7. /* XXX This needs to be mostly redone for sun5 SYSIO. */
  8.  
  9. #ifndef _SPARC64_SBUS_H
  10. #define _SPARC64_SBUS_H
  11.  
  12. #include <asm/oplib.h>
  13. #include <asm/iommu.h>
  14.  
  15. /* We scan which devices are on the SBus using the PROM node device
  16.  * tree.  SBus devices are described in two different ways.  You can
  17.  * either get an absolute address at which to access the device, or
  18.  * you can get a SBus 'slot' number and an offset within that slot.
  19.  */
  20.  
  21. /* The base address at which to calculate device OBIO addresses. */
  22. #define SUN_SBUS_BVADDR        0x00000000
  23. #define SBUS_OFF_MASK          0x0fffffff
  24.  
  25. /* These routines are used to calculate device address from slot
  26.  * numbers + offsets, and vice versa.
  27.  */
  28.  
  29. extern __inline__ unsigned long sbus_devaddr(int slotnum, unsigned long offset)
  30. {
  31.   return (unsigned long) (SUN_SBUS_BVADDR+((slotnum)<<28)+(offset));
  32. }
  33.  
  34. extern __inline__ int sbus_dev_slot(unsigned long dev_addr)
  35. {
  36.   return (int) (((dev_addr)-SUN_SBUS_BVADDR)>>28);
  37. }
  38.  
  39. extern __inline__ unsigned long sbus_dev_offset(unsigned long dev_addr)
  40. {
  41.   return (unsigned long) (((dev_addr)-SUN_SBUS_BVADDR)&SBUS_OFF_MASK);
  42. }
  43.  
  44. struct linux_sbus;
  45.  
  46. /* Linux SBUS device tables */
  47. struct linux_sbus_device {
  48.   struct linux_sbus_device *next;      /* next device on this SBus or null */
  49.   struct linux_sbus_device *child;     /* For ledma and espdma on sun4m */
  50.   struct linux_sbus *my_bus;           /* Back ptr to sbus */
  51.   int prom_node;                       /* PROM device tree node for this device */
  52.   char prom_name[32];                  /* PROM device name */
  53.  
  54.   struct linux_prom_registers reg_addrs[PROMREG_MAX];
  55.   int num_registers, ranges_applied;
  56.  
  57.   unsigned int irqs[4];
  58.   int num_irqs;
  59.  
  60.   unsigned long sbus_addr;             /* Absolute base address for device. */
  61.   unsigned long sbus_vaddrs[PROMVADDR_MAX];
  62.   unsigned long num_vaddrs;
  63.   unsigned long offset;                /* Offset given by PROM */
  64.   int slot;
  65. };
  66.  
  67. /* This struct describes the SBus(s) found on this machine. */
  68. struct linux_sbus {
  69.     struct linux_sbus *next;             /* next SBus, if more than one SBus */
  70.     struct linux_sbus_device *devices;   /* Link to devices on this SBus */
  71.     struct iommu_struct *iommu;          /* IOMMU for this sbus if applicable */
  72.     int prom_node;                       /* PROM device tree node for this SBus */
  73.     char prom_name[64];                  /* Usually "sbus" or "sbi" */
  74.     int clock_freq;
  75.     struct linux_prom_ranges sbus_ranges[PROMREG_MAX];
  76.     int num_sbus_ranges;
  77.     int upaid;
  78.     void *starfire_cookie;
  79. };
  80.  
  81. extern struct linux_sbus *SBus_chain;
  82.  
  83. /* Device probing routines could find these handy */
  84. #define for_each_sbus(bus) \
  85.         for((bus) = SBus_chain; (bus); (bus)=(bus)->next)
  86.  
  87. #define for_each_sbusdev(device, bus) \
  88.         for((device) = (bus)->devices; (device); (device)=(device)->next)
  89.         
  90. #define for_all_sbusdev(device, bus) \
  91.     for((bus) = SBus_chain, ((device) = (bus) ? (bus)->devices : 0); (bus); (device)=((device)->next ? (device)->next : ((bus) = (bus)->next, (bus) ? (bus)->devices : 0)))
  92.  
  93. extern void mmu_set_sbus64(struct linux_sbus_device *, int);
  94.  
  95. /* If you did not get the buffer from mmu_get_*() or sparc_alloc_dvma()
  96.  * then you must use this to get the 32-bit SBUS dvma address.
  97.  * And in this case it is your responsibility to make sure the buffer
  98.  * is GFP_DMA, ie. that it is not greater than MAX_DMA_ADDRESS.
  99.  */
  100. extern unsigned long phys_base;
  101. #define sbus_dvma_addr(__addr)    ((__u32)(__pa(__addr) - phys_base))
  102.  
  103. /* Apply promlib probed SBUS ranges to registers. */
  104. extern void prom_apply_sbus_ranges(struct linux_sbus *sbus, 
  105.                    struct linux_prom_registers *sbusregs, int nregs, 
  106.                    struct linux_sbus_device *sdev);
  107.  
  108. #endif /* !(_SPARC64_SBUS_H) */
  109.